package com.gofunbuy.app.member;

import com.gofunbuy.R;
import com.gofunbuy.TabMemberGroup;
import com.gofunbuy.util.GoFunBuyUtils;
import com.gofunbuy.util.GoFunBuyUtils.LoginLevelXML;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class SubMemberFavorableDetailActivity extends Activity implements
		OnClickListener {
	private TextView tvBack, tvTitle;
	private TextView tvAuValue, tvAgValue, tvSuValue, tvNormalValue;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.member_favorable_detail_layout2);
		initLayout();
	}

	private void initLayout() {
		tvTitle = (TextView) findViewById(R.id.topbar_title);
		tvTitle.setText(R.string.title_favorable);
		tvBack = (TextView) findViewById(R.id.topbar_back);
		tvBack.setOnClickListener(this);
		tvAuValue = (TextView) findViewById(R.id.member_au_value);
		tvAgValue = (TextView) findViewById(R.id.member_ag_value);
		tvSuValue = (TextView) findViewById(R.id.member_cu_value);
		tvNormalValue = (TextView) findViewById(R.id.member_normal_value);
		if (GoFunBuyUtils.mLoginResult.levels.size() == 4) {
			tvAuValue.setText(GoFunBuyUtils.mLoginResult.levels.get(0).dep);
			tvAgValue.setText(GoFunBuyUtils.mLoginResult.levels.get(1).dep);
			tvSuValue.setText(GoFunBuyUtils.mLoginResult.levels.get(2).dep);
			tvNormalValue.setText(GoFunBuyUtils.mLoginResult.levels.get(3).dep);
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.topbar_back:
			startActivity(TabMemberActivity.class);
			break;
		}
	}

	private void startActivity(Class<?> a) {
		// 要跳转的Activity
		// Log.v("名字", a.getSimpleName() + " " + a.getName());
		Intent intent = new Intent(SubMemberFavorableDetailActivity.this, a);
		// 把Activity转换成一个Window，然后转换成View
		Window w = TabMemberGroup.group.getLocalActivityManager()
				.startActivity(a.getSimpleName(), intent);
		View view = w.getDecorView();
		// 设置要跳转的Activity显示为本ActivityGroup的内容
		TabMemberGroup.group.setContentView(view);
	}
}
